<include file="Public/header" />


<style>
    .layui-form-label{width:140px;}
</style>
<body>
    <div class="layui-form"  id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
        <div class="layui-form-item">
            <label class="layui-form-label">文章标题(ZH)</label>
            <div class="layui-input-black  layui-col-md5">
                <input type="text" name="title_zh" value="{$article['title_zh']}" lay-verify="required" placeholder="中文" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">文章标题(EN)</label>
            <div class="layui-input-black  layui-col-md5">
                <input type="text" name="title_en" value="{$article['title_en']}" lay-verify="required" placeholder="英文" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">日期</label>
            <div class="layui-input-black  layui-col-md5">
                <input type="text" class="layui-input" id="test1" name="add_time" <empty name='article["add_time"]'><else />value="{:date('Y-m-d',$article['add_time'])}"</empty>  placeholder="yyyy-MM-dd">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">文章类型</label>
            <div class="layui-input-black  layui-col-md5">
                <select name="article_type" value="{$article['title_zh']}" lay-verify="">
                    <!-- <option value="">请选择标签</option> -->
                    <option value="1" <if condition="$article['article_type'] eq 1">selected</if> >外汇基础知识</option>
                    <option value="2" <if condition="$article['article_type'] eq 2">selected</if> >外汇名词解释</option>
                    <option value="3" <if condition="$article['article_type'] eq 3">selected</if> >网站公告</option>
                </select>
            </div>
        </div>
        
        <div class="layui-form-item">
            <label class="layui-form-label">文章内容</label>
            <div class="layui-input-black  layui-col-md10" style="background:#fff;">
                <div class="layui-tab" lay-filter="test">
                    <ul class="layui-tab-title">
                        <li class="layui-this" lay-id="11">中文</li>
                        <li lay-id="22">英文</li>
                    </ul>
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <textarea name="content_zh" lay-verify="content_zh" id="demo" style="width: 400px; height: 150px;" autocomplete="off" class="layui-textarea">{$article['content_zh']}</textarea>
                        </div>
                        <div class="layui-tab-item">
                            <textarea name="content_en" lay-verify="content_en" id="demo1" style="width: 400px; height: 150px;" autocomplete="off" class="layui-textarea">{$article['content_en']}</textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        
        <div class="layui-form-item">
            <label class="layui-form-label">是否显示</label>
            <div class="layui-input-black  layui-col-md5">
                <input type="checkbox" lay-verify="" lay-filter="switchTest" <if condition="$article['id'] neq '' and $article['is_show'] eq '1'">checked=""<else /></if>  name="is_show" lay-skin="switch" lay-text="是|否">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-black  layui-col-md5">
                <input type="hidden" value="{$article['id']}" name="id">

                <input type="submit" value="添加" class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
            </div>
        </div>

    </div>

<include file="Public/bottom" />

</body>

</html>
<script>
    layui.config({
        base: '__PUBLIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'upload','laydate','layedit','table'],function() {
        var $ = layui.$,
        form = layui.form,
        laydate = layui.laydate,
        table = layui.table,
        layedit = layui.layedit,
        upload = layui.upload;

        form.render();

        var demo  = layedit.build('demo'); //建立编辑器
        var demo1 = layedit.build('demo1'); //建立编辑器
        form.verify({
            content_zh: function(value){
                layedit.sync(demo);
            },
            content_en: function(value){
                layedit.sync(demo1);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)');
        // 日期时间
        laydate.render({
            elem: '#test1'
        });
        

        //添加文章
        form.on('submit(LAY-app-contlist-search)', function(data){
            var field = data.field;
            layer.load(1,{
                shade:[0.3,'#fff']
            });
            $.ajax({
                url :"{:U('addArticle')}",
                type:'post',
                data:field,
                success:function(res){
                    if (res.status == 1) {
                        layer.msg(res.info , {icon:1},function(){
                            // parent.layer.closeAll();
                            parent.location.reload();
                            //执行重载
                            // parent.table.reload('LAY-app-content-list', {
                            //     where: field
                            // });
                        });
                    }else{
                        layer.msg(res.info,{icon:2});
                    }
                }
            });
        });

        
    });
</script>